package com.lottery.shadowbd.ui.fragment;


import android.content.Context;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.lottery.shadowbd.R;
import com.lottery.shadowbd.adapter.TabFragmentAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class LotAnalysisFragment extends BaseFragment {

    private View mView;

    private TabLayout tabLayout;

    private ViewPager viewPager;

    private List<Fragment> mFragments;
    private List<String> mTitles;

    private TabFragmentAdapter mFragmentAdapter;

    @Override
    protected View initView(LayoutInflater inflater) {
        mView = inflater.inflate(R.layout.fragment_lot_analysis, null);

        tabLayout = (TabLayout) mView.findViewById(R.id.tabLayout);

        viewPager = (ViewPager) mView.findViewById(R.id.viewPager);

        return mView;
    }

    @Override
    protected void initData() {
        mContext = getActivity();

        mFragments = new ArrayList<>(5);
        mTitles = new ArrayList<>(5);

        mFragments.add(new LotChartFragment());
        mFragments.add(new LotChartFragment());
        mFragments.add(new LotChartFragment());
        mFragments.add(new LotChartFragment());
        mFragments.add(new LotChartFragment());

        mTitles.add("1");
        mTitles.add("2");
        mTitles.add("3");
        mTitles.add("4");
        mTitles.add("5");

        tabLayout.addTab(tabLayout.newTab().setText(""));
        tabLayout.addTab(tabLayout.newTab().setText(""));
        tabLayout.addTab(tabLayout.newTab().setText(""));
        tabLayout.addTab(tabLayout.newTab().setText(""));
        tabLayout.addTab(tabLayout.newTab().setText(""));

        mFragmentAdapter = new TabFragmentAdapter(getChildFragmentManager(), mFragments, mTitles);

        viewPager.setOffscreenPageLimit(4);
        viewPager.setAdapter(mFragmentAdapter);
        tabLayout.setupWithViewPager(viewPager);
    }

    @Override
    protected void listener() {

    }

    @Override
    protected void widgetClick(View v) {

    }
}
